package com.lanou.controller;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @author lizhongren1.
 */
@WebServlet(urlPatterns = "/home")
public class HomeServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {



//        1112312
        // 判断用户是否处于登录状态
        HttpSession session = req.getSession();

        Object isLogin = session.getAttribute("isLogin");

        if (isLogin == null){
            // 没有登录
            resp.sendRedirect("/loginpage.html");
        } else {
            // 登录了
            req.getRequestDispatcher("/WEB-INF/home.html").forward(req,resp);
        }


    }
}
